package com.npjscg.medicalpro.controller;


import com.npjscg.medicalpro.common.Constants;
import com.npjscg.medicalpro.common.Result;
import com.npjscg.medicalpro.service.IBcheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author raote
 * @since 2022-07-09
 */
@Api(tags = "事务管理状态模块")
@RestController
@RequestMapping("/bcheck")
public class BcheckController {

    @Autowired
    private IBcheckService bcheckService;


    @ApiOperation(value = "管理员提供事务的id来改变status状态")
    @GetMapping("/changeStatus/{bid}/{currentStatus}/{adminid}")
    public Result changeStatus(@PathVariable Integer bid, @PathVariable int currentStatus, @PathVariable int adminid){
        if (bid == null)
            return Result.error(Constants.CODE_600, "id为空出错！");
        else{
            bcheckService.changeStatus(bid, currentStatus,adminid);
            return Result.success();
        }

    }


    @ApiOperation(value = "添加退回理由")
    @GetMapping("/changeMsg/{bid}/{msg}")
    public Result changeMsg(@PathVariable Integer bid, @PathVariable String msg){
        bcheckService.changeMsg(bid, msg);
        return Result.success();
    }
}
